package com.hhf.feicodebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hhf.feicodebackend.model.dto.chathistory.ChatHistoryQueryRequest;
import com.hhf.feicodebackend.model.entity.ChatHistory;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hhf.feicodebackend.model.entity.User;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;

import java.time.LocalDateTime;

/**
 * @author 86138
 * @description 针对表【chat_history(对话历史)】的数据库操作Service
 * @createDate 2025-08-14 16:23:13
 */
public interface ChatHistoryService extends IService<ChatHistory> {

    int loadChatHistoryToMemory(Long appId, MessageWindowChatMemory chatMemory, int maxCount);

    /**
     * 添加对话消息
     *
     * @param appId
     * @param message
     * @param messageType
     * @param userId
     * @return
     */
    boolean addChatMessage(Long appId, String message, String messageType, Long userId);

    /**
     * 根据appId删除对话消息
     *
     * @param appId
     * @return
     */
    boolean deleteByAppId(Long appId);

    /**
     * 获取appId的分页对话消息
     *
     * @param appId
     * @param pageSize
     * @param lastCreateTime
     * @param loginUser
     * @return
     */
    Page<ChatHistory> listAppChatHistoryByPage(Long appId, int pageSize,
                                               LocalDateTime lastCreateTime,
                                               User loginUser);


    QueryWrapper getQueryWrapper(ChatHistoryQueryRequest chatHistoryQueryRequest);
}
